<div class="busmanager">
	<android:input label="快速搜索" description="输入商家相关信息（手机号码、商家号、店铺名、邮箱、店铺地址等商家信息） 进行模糊查找" bind-input="{{'$Cache.admin.busmanager.search_text'}}" event-input="{{'$Event.admin.busmanager.search'}}"></android:input>
	<table class="paper-table">
		<thead>
			<td><h6>编号<button class="{{$Cache.admin.busmanager.bus_sort_way?'icon-arrow-up':'icon-arrow-down'}}" event-click="{{'$Event.admin.busmanager.bus_sort'}}"></button></h6></td>
			<td><h3>商家名</h3></td>
			<td><h3>店铺名</h3></td>
			<td><h3>审核状态</h3></td>
			<td><h3>高级设置</h3></td>
		</thead>
	{{#if !$Cache.admin.busmanager.bus_list.length}}
	<tr>
		<td rowspan="5"><h4>载入中，请稍候……</h4></td>
	</tr>
	{{/if}}
	{{#> "admin_searching_bus_list","$This",$Cache.admin.busmanager.is_searching}}
	{{#> "admin_bus_list","$This",!$Cache.admin.busmanager.is_searching}}
	</table>
<!-- 	
jSouper.parse('
	<table>
		<thead>
			<td>商家名</td>
			<td>域名</td>
			<td>邮箱</td>
			<td>手机号码</td>
			<td>建站时间</td>
			<td>到期时间</td>
			<td>开通的功能</td>
		</thead>
		{{#each $Cache.admin.busmanager.bus_list}}
		<tr>
			<td>{{info.title}}</td>
			<td>{{info.domain_url}}</td>
			<td>{{info.email}}</td>
			<td>{{info.mobile_phone}}</td>
			<td>{{#Time create_time,"YYYY-MM-DD"}}</td>
			<td>{{#Time expiration_time,"YYYY-MM-DD"}}</td>
			<td>
{{permission.can_set_goods_call_back_buff?"商品支付回调,":""}}
{{permission.can_sale_virtual_goods?"商品虚拟交易,":""}}
{{permission.can_only_online_pay?"禁止商品货到付款,":""}}
{{permission.can_invite_bus?"邀请好友开站,":""}}
{{permission.can_set_theme?"修改风格包,":""}}
{{permission.can_goods_be_bina?"商品二级分销":""}}
			</td>
		</tr>
		{{/each}}
	</table> 
')(App.getModel()).append(document.body)
	-->
</div>
<xmp type="template" name="admin_bus_setting">
	<tr>
		<td><span class="icon-arrow-up "></span></td>
		<td colspan="4">
		<div>
		<div>
			<h4>审核操作：</h4>
			{{#if status==$Top.config.admin.BUS_STATE.未审核}}
			<android:paperButton event-click="{{'$Top.$Event.admin.bus_state.to_审核中'}}">进行审核</android:paperButton> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.审核中}}
			<android:paperButton event-click="{{'$Top.$Event.admin.bus_state.to_审核未通过'}}">不通过</android:paperButton>  
			<android:paperButton event-click="{{'$Top.$Event.admin.bus_state.to_审核通过'}}">通过审核</android:paperButton> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.审核通过}}
			<android:paperButton event-click="{{'$Top.$Event.admin.bus_state.to_冻结'}}">冻结商家</android:paperButton> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.审核未通过}}
			<android:paperButton event-click="{{'$Top.$Event.admin.bus_state.to_审核中'}}">重新审核</android:paperButton> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.冻结}}
			<android:paperButton event-click="{{'$Top.$Event.admin.bus_state.to_审核中'}}">解冻并重新审核</android:paperButton> 
			{{/if}}
		</div>
		<div>
			<h4 class="icon-cogs">功能设置：</h4>
            <android:switch checked="{{permission.can_set_goods_call_back_buff}}" bind-input="{{'permission.can_set_goods_call_back_buff'}}" event-change="{{'$Top.$Event.admin.bus_can_set_goods_call_back_buff.toggle'}}">
            商品支付回调<b>{{permission.can_set_goods_call_back_buff?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_sale_virtual_goods}}" bind-input="{{'permission.can_sale_virtual_goods'}}" event-change="{{'$Top.$Event.admin.bus_can_sale_virtual_goods.toggle'}}">
            商品虚拟交易<b>{{permission.can_sale_virtual_goods?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_only_online_pay}}" bind-input="{{'permission.can_only_online_pay'}}" event-change="{{'$Top.$Event.admin.bus_can_only_online_pay.toggle'}}">
            禁止商品货到付款<b>{{permission.can_only_online_pay?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_invite_bus}}" bind-input="{{'permission.can_invite_bus'}}" event-change="{{'$Top.$Event.admin.bus_can_invite_bus.toggle'}}">
            邀请好友开站<b>{{permission.can_invite_bus?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_set_theme}}" bind-input="{{'permission.can_set_theme'}}" event-change="{{'$Top.$Event.admin.bus_can_set_theme.toggle'}}">
            修改风格包<b>{{permission.can_set_theme?'允许':'禁止'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_goods_be_bina}}" bind-input="{{'permission.can_goods_be_bina'}}" event-change="{{'$Top.$Event.admin.bus_can_goods_be_bina.toggle'}}">
            商品二级分销<b>{{permission.can_goods_be_bina?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_bina_to_third}}" bind-input="{{'permission.can_bina_to_third'}}" event-change="{{'$Top.$Event.admin.bus_can_bina_to_third.toggle'}}">
            商品三级分销<b>{{permission.can_bina_to_third?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch title="无需购买商品即可使用分销" checked="{{permission.bina_no_need_buy}}" bind-input="{{'permission.bina_no_need_buy'}}" event-change="{{'$Top.$Event.admin.bus_bina_no_need_buy.toggle'}}">
            分享分销<b>{{permission.bina_no_need_buy?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_multi_bina}}" bind-input="{{'permission.can_multi_bina'}}" event-change="{{'$Top.$Event.admin.bus_can_multi_bina.toggle'}}">
            分销商品可多次购买<b>{{permission.can_multi_bina?'开启':'关闭'}}</b>
            </android:switch>
            <android:switch checked="{{permission.can_municipal_agency}}" bind-input="{{'permission.can_municipal_agency'}}" event-change="{{'$Top.$Event.admin.bus_can_municipal_agency.toggle'}}">
            市代功能<b>{{permission.can_municipal_agency?'开启':'关闭'}}</b>
            </android:switch>
            
            <div>
            上传商品数量上限
            <inputnumber value="{{permission.data_max_goods_num||$Top.config.server_config.defaultMaxGoodsNum}}" bind-input="{{'permission.data_max_goods_num'}}" fixed="0" loop="1" min="0" event-change="{{'$Top.$Event.admin.set_bus_max_goods_num'}}"></inputnumber>
            </div>

		</div>
		<div class="">
			<h4>导航设置</h4>
			<!-- <p>{{perms}}</p> -->
		<!-- 	{{#if $Private.show_permission_edit}}
			<android:paperbutton event-click="{{'$Top.$Event.admin.close_permission_edit'}}">关闭导航设置</android:paperbutton>
			{{#else}}
			<android:paperbutton event-click="{{'$Top.$Event.admin.open_permission_edit'}}">自定义导航设置</android:paperbutton>
			{{/if}} -->
			<android:switch event-change="{{'$Top.$Event.admin.reset_bus_perms'}}" checked="{{!perms}}">{{perms?'自定义导航设置':'使用默认导航设置'}}</android:switch>
			{{#> "admin_permission_manage","$This",perms}}
		</div>
		<div>
			<h4 class="icon-newspaper">商家注册信息：</h4>
			<div class="logo">
				{{#if info.logo_url}}
					<img bind-src="{{info.logo_url}}?imageView/1/w/80/h/80">
				{{#else}}
					<i>商家未上传LOGO</i>
				{{/if}}
			</div>
			<p>商家名：{{info.title}}</p>
			<p>邮箱：{{info.email}}</p>
			<p>手机号码：{{info.mobile_phone}}</p>
			<p>建站时间：{{#Time create_time,"YYYY-MM-DD"}}</p>
			<p>到期时间：<span style="display:inline-block;"><android:datePicker value="{{expiration_time}}" bind-input="{{'expiration_time'}}" event-change="{{'$Top.$Event.admin.update_bus_expiration_time'}}">修改</android:datePicker></span></p>
			<p>邀请者：{{#if pid}} <b>{{pid}}</b>{{#else}}<i>无</i>{{/if}}</p>
			<p>手机版风格：
				<label for="mobile_theme_name_1">
					<input type="radio" id="mobile_theme_name_1" value="普通单排" checked="{{permission.data_mobile_theme_name||'普通单排'}}" bind-input="{{'permission.data_mobile_theme_name'}}"  event-change="{{'$Top.$Event.admin.set_bus_mobile_theme_name'}}"/>普通单排（默认）
				</label>
				<label for="mobile_theme_name_2">
					<input type="radio" id="mobile_theme_name_2" value="普通双排" checked="{{permission.data_mobile_theme_name}}" bind-input="{{'permission.data_mobile_theme_name'}}"  event-change="{{'$Top.$Event.admin.set_bus_mobile_theme_name'}}"/>普通双排
				</label>
				<label for="mobile_theme_name_3">
					<input type="radio" id="mobile_theme_name_3" value="餐饮行业" checked="{{permission.data_mobile_theme_name}}" bind-input="{{'permission.data_mobile_theme_name'}}"  event-change="{{'$Top.$Event.admin.set_bus_mobile_theme_name'}}"/>餐饮行业
				</label>
			</p>
			<p>电脑版风格：
				<label for="management_category_1">
					<input type="radio" id="management_category_1" value="商店" checked="{{permission.data_management_category||'商店'}}" bind-input="{{'permission.data_management_category'}}"  event-change="{{'$Top.$Event.admin.bus_data_management_category.toggle'}}"/>商店（默认）
				</label>
				<label for="management_category_2">
					<input type="radio" id="management_category_2" value="餐饮" checked="{{permission.data_management_category}}" bind-input="{{'permission.data_management_category'}}"  event-change="{{'$Top.$Event.admin.bus_data_management_category.toggle'}}"/>餐饮
				</label>
			</p>
			<p>新版手机风格：<br>
			<android:selectsearch placeholder="手机风格包名" use-value-as-result="true" bind-input="{{'permission.data_mobile_template_name'}}" value="{{permission.data_mobile_template_name}}" event-change="{{'$Top.$Event.admin.bus_data_mobile_template_name.toggle'}}">
				{{#each $Top.$Cache.admin.busmanager.dotnar_template_list}}
				<optionItem value="{{userName+'/'+name}}" title="{{package.description}} [{{url}}]">{{package.template_name?package.template_name:userName+'/'+name}}</optionItem>
				{{/each}}
			</android:selectsearch>
			<!-- 
			<android:input label="手机风格包名" description="目前风格包平台尚未放出，如非开发人员，请勿对此项信息进行操作" bind-input="{{'permission.data_mobile_template_name'}}" value="{{permission.data_mobile_template_name}}" event-change="{{'$Top.$Event.admin.bus_data_mobile_template_name.toggle'}}"></android:input> --></p>
			<p>新版电脑风格：<br>
			<android:selectsearch placeholder="手机风格包名" use-value-as-result="true" bind-input="{{'permission.data_pc_template_name'}}" value="{{permission.data_pc_template_name}}" event-change="{{'$Top.$Event.admin.bus_data_pc_template_name.toggle'}}">
				{{#each $Top.$Cache.admin.busmanager.dotnar_template_list}}
				<optionItem value="{{userName+'/'+name}}" title="{{package.description}} [{{url}}]">{{package.template_name?package.template_name:userName+'/'+name}}</optionItem>
				{{/each}}
			</android:selectsearch>
			<!-- 
			<android:input label="电脑风格包名" description="目前风格包平台尚未放出，如非开发人员，请勿对此项信息进行操作" bind-input="{{'permission.data_pc_template_name'}}" value="{{permission.data_pc_template_name}}" event-change="{{'$Top.$Event.admin.bus_data_pc_template_name.toggle'}}"></android:input> --></p>
		</div>
		<div>
			<h4 class="icon-wrench">商家操作：</h4>
			<android:paperButton event-click="{{'$Top.$Event.admin.busmanager.remove_bus'}}">删除商家</android:paperButton> 
		</div>
		</div>
		</td>
	</tr>
	<tr>
		<td colspan="5" style="border:1px #333 solid;border-width:0 1px 1px 1px;"></td>
	</tr>
</xmp>
<xmp type="template" name="admin_bus_list_item">
	<tr>
		<td class="index-num">{{$Index+1}}</td>
		<td>{{info.name||_id}}</td>
		<td>
		{{#if info.domain_url}}
			<a target="_blank" title="{{info.domain_url}}" href="{{info.domain_url}}">{{info.title}}</a>
		{{#else}}
			{{info.title}}<i style="color:#666;" >（无绑定域名）</i>
		{{/if}}
		</td>
		<td class="state">
			{{#if status==$Top.config.admin.BUS_STATE.未审核}}
			<span>未审核 </span> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.审核中}}
			<span>审核中 </span> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.审核通过}}
			<span>审核通过 </span> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.审核未通过}}
			<span>审核未通过 </span> 
			{{/if}}
			{{#if status==$Top.config.admin.BUS_STATE.冻结}}
			<span>商家已经冻结 </span> 
			{{/if}}
		</td>
		<td class="operation">
		{{#if $Private.$Cache.show_setting}}
			<android:paperButton event-click="{{'$Top.$Event.admin.busmanager.close_setting'}}">收起<span class="icon-contract button-icon"></span></android:paperButton>
		{{#else}}
			<android:paperButton event-click="{{'$Top.$Event.admin.busmanager.open_setting'}}">展开<span class="icon-expand button-icon"></span></android:paperButton>
		{{/if}}
	</tr>
	{{#> "admin_bus_setting","$This",$Private.$Cache.show_setting}}
</xmp>
<xmp type="template" name="admin_bus_list">
	{{#each $Cache.admin.busmanager.showing_bus_list}}
		{{#> "admin_bus_list_item"}}
		{{#> "admin_bus_setting","$This",$Private.$Cache.show_setting}}
	{{/each}}
	{{#if $Cache.admin.busmanager.bus_list.length>$Cache.admin.busmanager.showing_bus_list.length}}
	<tr><td class="show-more" colspan="5" event-click="{{'$Event.admin.busmanager.show_more'}}">显示更多</td></tr>
	{{/if}}
</xmp>
<xmp type="template" name="admin_searching_bus_list">
	{{#each $Cache.admin.busmanager.searching_bus_list}}
		{{#> "admin_bus_list_item"}}
		{{#> "admin_bus_setting","$This",$Private.$Cache.show_setting}}
	{{/each}}
	{{#if !$Cache.admin.busmanager.searching_bus_list.length}}
	<tr>
		<td rowspan="5"><h4>未找到匹配的商家</h4></td>
	</tr>
	{{/if}}
</xmp>
<xmp type="template" name="admin_permission_manage">
	<table class="admin-permission-manage paper-table">
		<thead>
		{{#each $Private._perms_renderable}}
		<td>{{name}}</td>
		{{/each}}
		</thead>
		<tr>
			{{#each $Private._perms_renderable}}
			<td>
				<div>
				{{#each items}}
					<div>
						<android:array-checkbox source-value="{{window._pers_item_childs_to_keys(childs)}}" bind-input="{{'$Caller.$Caller.perms'}}" source-checked="{{$Caller.$Caller.perms}}" event-change="{{'$Caller.$Caller.$Top.$Event.admin.busmanager.update_bus_perms'}}">{{title}}</android:array-checkbox>
						<div class="list">
						{{#each childs}}
							<div>
								<android:checkbox checked="{{window._pers_childs_in_keys($Caller.$Caller.$Caller.perms, hash)}}" event-change="{{'$Caller.$Caller.$Caller.$Private.$Event.toggle_checkbox'}}">{{title}}</android:checkbox>
							</div>
						{{/each}}
						</div>
					</div>
				{{/each}}
				</div>
			</td>
			{{/each}}
		</tr>
	</table>
	<script type="text/vm">
	function(vm) {
		var bus_permission = require("bus_permission");
		vm.set("$Private.$Event.toggle_checkbox", function(e, cvm) {
			var keys = vm.get("perms") || [];
			var _child_keys = bus_permission.hash_to_keys(cvm.get("hash"));
			if (this.checked) {
				keys.push.apply(keys, _child_keys)
			} else {
				jSouper.forEach(_child_keys, function(key) {
					keys = jSouper.$.rm(keys, key)
				});
			}
			vm.set("perms", keys);
		});
		vm.set("$Private._perms_renderable", bus_permission.tree_to_renderable(bus_permission.pers_name_map))
	}
	</script>
</xmp>
<style>
	.admin-permission-manage.paper-table tr td{
		vertical-align: top;
		/*text-align: center;*/
	}
	.admin-permission-manage.paper-table tr td .list{
		padding-left: 1.5em;
	}
</style>